﻿//Uncomment the following line to connect to the server
//#define CONNECT_TO_SERVER

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.IO;
using NexTrackDesktop.Media;
using NexTrackDesktop.NexTrack;
using NexTrackDesktop.ViewModels;

namespace NexTrackDesktop
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            //When the Application is started, the Client object needs to be
            //created because it glues together the entire application.
            Client Client;

#if CONNECT_TO_SERVER
            Client = new Client(new NexTrackServiceAdapter());
#else
            Client = new Client(new MainServiceMock());
#endif


            //The library file is located in %APP_DATA%\NexTrack\library.xml
            string libraryLocation = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                "NexTrack", "library.xml");

            ILibrarySource appDataSource = new LibraryXMLFileSource(libraryLocation);

            //TODO: use the Album Art tagger
            Library lib = new Media.Library(new TagLibTagger(), appDataSource);
            Client.MediaLibrary = lib;

            //All viewmodels will have access to this client.a
            ViewModelBase.Client = Client;
        }


    }
}
